home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / evilswitch.swf / scripts / DefineSprite_20_mc.selector / frame_1 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  2.2 KB  |  83 lines

  1. this.init = function()
  2. {
  3.    this.pPosX = this.pPosY = 3;
  4.    this.pPosNum = this.pPosY * 8 + this.pPosX;
  5.    this._x = 20 + (this.pPosX - 4) * 40;
  6.    this._y = 20 + (this.pPosY - 4) * 40;
  7.    this.pSelection = -1;
  8.    this.pActive = false;
  9.    this.pVisible = true;
  10.    this.hilite1_mc._visible = false;
  11.    this.hilite2_mc._visible = false;
  12.    this.hilite3_mc._visible = false;
  13.    this.hilite4_mc._visible = false;
  14.    this.hideSelector();
  15.    this.pSelectSnd = new Sound(this);
  16.    this.pSelectSnd.attachSound("snd.select");
  17. };
  18. this.setActive = function(tState)
  19. {
  20.    this.pActive = tState;
  21.    if(tState)
  22.    {
  23.       this._x = 20 + (this.pPosX - 4) * 40;
  24.       this._y = 20 + (this.pPosY - 4) * 40;
  25.    }
  26. };
  27. this.hideSelector = function()
  28. {
  29.    this._y = -200;
  30. };
  31. this.removeSelector = function()
  32. {
  33.    this.removeMovieClip();
  34. };
  35. this.moveSelect = function(aX, aY)
  36. {
  37.    this.pPosX += aX;
  38.    this.pPosY += aY;
  39.    this.pPosX = Math.max(0,Math.min(7,this.pPosX));
  40.    this.pPosY = Math.max(0,Math.min(7,this.pPosY));
  41.    this._x = 20 + (this.pPosX - 4) * 40;
  42.    this._y = 20 + (this.pPosY - 4) * 40;
  43.    if(this.pSelection != -1)
  44.    {
  45.       if(this.pSelection != this.pPosY * 8 + this.pPosX)
  46.       {
  47.          this._parent.swapBlocks(this.pSelection,this.pPosY * 8 + this.pPosX);
  48.          this.pSelection = -1;
  49.          this.gotoAndStop("hilite");
  50.          this.hilite1_mc._visible = false;
  51.          this.hilite2_mc._visible = false;
  52.          this.hilite3_mc._visible = false;
  53.          this.hilite4_mc._visible = false;
  54.       }
  55.    }
  56. };
  57. this.pressSelect = function()
  58. {
  59.    if(this.pActive)
  60.    {
  61.       if(this.pSelection == -1)
  62.       {
  63.          this.pSelection = this.pPosY * 8 + this.pPosX;
  64.          this.gotoAndStop("select");
  65.          this.hilite1_mc._visible = true;
  66.          this.hilite2_mc._visible = true;
  67.          this.hilite3_mc._visible = true;
  68.          this.hilite4_mc._visible = true;
  69.          this.pSelectSnd.start();
  70.       }
  71.       else
  72.       {
  73.          this.pSelection = -1;
  74.          this.gotoAndStop("hilite");
  75.          this.hilite1_mc._visible = false;
  76.          this.hilite2_mc._visible = false;
  77.          this.hilite3_mc._visible = false;
  78.          this.hilite4_mc._visible = false;
  79.       }
  80.    }
  81. };
  82. this.init();
  83.